package uba.fi.tda.tp1.service;

import java.util.Arrays;

import uba.fi.tda.tp1.sorts.BubbleSort;
import uba.fi.tda.tp1.sorts.InsertionSort;
import uba.fi.tda.tp1.sorts.MergeSort;
import uba.fi.tda.tp1.sorts.QuickSort;
import uba.fi.tda.tp1.sorts.SelectionSort;
import uba.fi.tda.tp1.sorts.ShellSort;
import uba.fi.tda.tp1.utils.Array;
import uba.fi.tda.tp1.utils.NumbersBuilder;

public class Service {

	private BubbleSort bubbleSort = new BubbleSort();
	private InsertionSort insertionSort = new InsertionSort();
	private SelectionSort selectionSort =  new SelectionSort();
	private ShellSort shellSort = new ShellSort();
	private QuickSort quickSort = new QuickSort();
	private MergeSort mergeSort = new MergeSort();
	
	/**
	 * Ejecuta todos los metodos de ordenamiento
	 * @param N cantidad de elementos con los cuales se quiere trabajar
	 */
	public void execute(int N) {
		
		NumbersBuilder numbers = new NumbersBuilder(N);
		
		int[] resultBubble = bubbleSort.sort(numbers.getNumbers());			
		
		int[] resultInsertion = insertionSort.sort(numbers.getNumbers());
		
		int[] resultSelection = selectionSort.sort(numbers.getNumbers());
		
		int[] resultShell = shellSort.sort(numbers.getNumbers());
		
		int[] resultQuick = quickSort.sort(numbers.getNumbers());
		
		int[] resultMerge = mergeSort.sort(numbers.getNumbers());


		//Original
		System.out.println("Entrada = " + Array.toString(numbers.getNumbers()));

		//Ordenados
		System.out.println("Bubble: " + bubbleSort.getLastSortTime() + " us;" + Array.toString(resultBubble));
		System.out.println("Insertion: " + insertionSort.getLastSortTime() + " us;" + Array.toString(resultInsertion));
		System.out.println("Selection: " + selectionSort.getLastSortTime() + " us;" + Array.toString(resultSelection));
		System.out.println("ShellSort: " + shellSort.getLastSortTime() + " us;" + Array.toString(resultShell));
		System.out.println("QuickSort: " + quickSort.getLastSortTime() + " us;" + Array.toString(resultQuick));
		System.out.println("MergeSort: " + mergeSort.getLastSortTime() + " us;" + Array.toString(resultMerge));


	
	}
}
